#ifndef BIMOSCONTROL_H
#define BIMOSCONTROL_H

#include <QMainWindow>
#include <QMap>

#include "View/view.h"
#include "Connectivity/connectivity.h"
#include "Wizard/newproject.h"
#include "Wizard/calibration.h"
#include "Control/config.h"
#include "Model/BimosSensorPressure.h"
#include "Model/bimossensorabsolute.h"
#include "Model/bimossensortemperature.h"
#include "Model/bimossensorgroup.h"

namespace Ui {
class BimosControl;
}

class BimosControl : public QMainWindow
{
    Q_OBJECT
    
public:
    explicit BimosControl(QWidget *parent = 0);
    ~BimosControl();

    NewProject *wizard;
    Calibration *wizardCal;
    View *bView;

    Connectivity *bHandler;
    Config *config;


    QMap<int, BimosSensorPressure *> *getSensorList();
    bool setSensorState(bool newState, int ordinal);



private:
    Ui::BimosControl *ui;
    void setupGraphics();
    void setupBimosBox();
    void startProject();
    //void initializePackages();
    void askUserForFinishEvacuation();

    void freezeProject();

    //TODO add ENUM to BimoSensor to distinguish between sensor type
    BimosSensorAbsolute *absolutePressure;
    BimosSensorTemperature *temperatureSensor;

    QMap<int, BimosSensorPressure*> activeSensorList;
    QMap<int, BimosSensorPressure*> inactiveSensorList;

    QMap<int, BimosSensorPressure*> tmpCloneList;

    bool saveConfig();

    // Saving data
    void startSavingData();

    QTimer* saveDataTimer;
    QTextStream* out;
    QFile* file;public slots:
    void showWizard();
    void showCalibration();

    bool loadConfig();

    void receiveNewSensorValue(int ordinal, double value);

    void evacuateBottle();
    void setPrepressureToBottle();
    void saveDataToFile();
signals:
    void sensorStateChanged(int ordinal, bool state);
    void newAbsoluteSensorValue(double);
    void newTemperatureSensorValue(double);

};

#endif // BIMOSCONTROL_H
